/**
 * @Title: IndexController.java
 * @Package com.zll.ccp.controller
 * @author zhanglinlu
 * @date 2019年4月28日 下午3:34:57
 */
package com.zll.ccp.controller;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zll.ccp.service.IIndexService;
import com.zll.ccp.utils.CommonUtils;

/**
 * @ClassName: IndexController
 * @Description: 主页controller
 * @author zhanglinlu
 * @date 2019年4月28日 下午3:34:57
 * 
 */
@Controller
public class IndexController {
    @Autowired
    private IIndexService indexService;

    /**
     * @Title: index
     * @Description: 跳转到主页
     * @return 主页
     */
    @RequestMapping("/index")
    public String index() {
        return "index";
    }

    /**
     * @Title: getShareTopfive
     * @Description: 获取主页 分享榜
     * @param isAll
     * @return
     */
    @GetMapping("/sharetopfive")
    @ResponseBody
    public Object getShareTopfive(boolean isAll) {
        String yearMonth = null;
        // 月榜
        if (!isAll) {
            yearMonth = DateFormatUtils.format(CommonUtils.getNowDate(), "yyyy-MM");
        }
        return indexService.getUserShareCount(yearMonth);
    }

    /**
     * @Title: getAnnouncesTop
     * @Description: 公告top5
     * @return
     */
    @GetMapping("/announcestop")
    @ResponseBody
    public Object getAnnouncesTop() {
        return indexService.getAnnouncesTop();
    }
}
